/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/graphics.hpp>
#include <journal/views/camera.h>
#include <journal/views/light.hpp>

namespace journal { namespace view {

namespace b = baja;
namespace g = baja::graphics;

class scene_state : public std::enable_shared_from_this<scene_state>
{
public:
    scene_state();
    void apply(const std::shared_ptr<g::iengine>& graphics);
    void setAmbient(const g::color& ambient);

    const g::color& ambient() const { return _ambient; }
    std::shared_ptr<icamera> getCamera() { return _camera; }
    std::shared_ptr<light> getLight() { return _light; }

private:

    void onLightChange(const std::shared_ptr<journal::view::light>& l);

    bool _dirty;
    m::matrix44 _coordinateSystemMatrix;
    m::matrix44 _worldMatrix;
    std::shared_ptr<light> _light;
    g::color _ambient;
    std::shared_ptr<icamera> _camera;
};

}} // namespace journal::view